﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;

namespace Kay.Communication.Framework.Custom_EventArgs
{
    /// <summary>
    /// 为 Udp 消息提供数据
    /// </summary>
    public class UdpMessageReceivedEventArgs : EventArgs
    {
        /// <summary>
        /// 初始化数据
        /// </summary>
        /// <param name="endPoint">消息来源的网络地址</param>
        /// <param name="id">消息标识</param>
        /// <param name="info">数据包信息</param>
        /// <exception cref="ArgumentNullException">如果有参数为 null，将引发异常</exception>
        public UdpMessageReceivedEventArgs(EndPoint endPoint, string id, params UdpDataPackageInfo[] info)
        {
            if (endPoint == null)
                throw new ArgumentNullException("endPoint");
            if (id == null)
                throw new ArgumentNullException("id");
            if (info == null)
                throw new ArgumentNullException("info");
            RemoteEndPoint = endPoint;
            Id = id;
            Info = info.ToList();
        }

        /// <summary>
        /// 获取或设置远程网络地址
        /// </summary>
        public EndPoint RemoteEndPoint { get; set; }

        /// <summary>
        /// 获取或设置消息标识
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 获取或设置消息信息
        /// </summary>
        public List<UdpDataPackageInfo> Info { get; set; }
    }
}